package mm.card.dao.model;

import java.math.BigDecimal;
import java.util.Date;

import mm.card.util.AesUtil;
import mm.card.util.BigDecimalUtil;
import mm.card.util.DateUtil;

public class CardAgentInfo {

	public CardAgentInfo() {
	}

	public CardAgentInfo(CardTable2 tb) throws Exception {
		this.id = tb.getId();
		this.agentId = AesUtil.decrypt(tb.getAttribute1());
		this.rate = new BigDecimal(AesUtil.decrypt(tb.getAttribute2()));
		this.userRole = AesUtil.decrypt(tb.getAttribute3());
		this.parentAgentId = AesUtil.decrypt(tb.getAttribute4());
		this.accountBalance = new BigDecimal(AesUtil.decrypt(tb.getAttribute5()));
		this.userName = AesUtil.decrypt(tb.getAttribute6());
		this.password = AesUtil.decrypt(tb.getAttribute7());
		this.name = AesUtil.decrypt(tb.getAttribute8());
		this.linkman = AesUtil.decrypt(tb.getAttribute9());
		this.linkmanPhone = AesUtil.decrypt(tb.getAttribute10());
		this.registTime = DateUtil.str2DateTime(AesUtil.decrypt(tb.getAttribute11()));
		this.lastLoginTime = DateUtil.str2DateTime(AesUtil.decrypt(tb.getAttribute12()));
		this.pwdErrCount = Integer.valueOf(AesUtil.decrypt(tb.getAttribute13()));
		this.isLock = Integer.valueOf(AesUtil.decrypt(tb.getAttribute14()));
		this.isActive = Integer.valueOf(AesUtil.decrypt(tb.getAttribute15()));
		this.isValid = Integer.valueOf(AesUtil.decrypt(tb.getAttribute16()));
		this.isDelete = Integer.valueOf(AesUtil.decrypt(tb.getAttribute17()));
	}

	public CardTable2 toCardTable2() throws Exception {
		CardTable2 tb = new CardTable2();
		tb.setId(this.id);
		tb.setAttribute1(AesUtil.encrypt(this.agentId));
		tb.setAttribute2(AesUtil.encrypt(BigDecimalUtil.millionthFormat(this.rate)));
		tb.setAttribute3(AesUtil.encrypt(this.userRole));
		tb.setAttribute4(AesUtil.encrypt(this.parentAgentId));
		tb.setAttribute5(AesUtil.encrypt(BigDecimalUtil.millionthFormat(accountBalance)));
		tb.setAttribute6(AesUtil.encrypt(this.userName));
		tb.setAttribute7(AesUtil.encrypt(this.password));
		tb.setAttribute8(AesUtil.encrypt(this.name));
		tb.setAttribute9(AesUtil.encrypt(this.linkman));
		tb.setAttribute10(AesUtil.encrypt(this.linkmanPhone));
		tb.setAttribute11(AesUtil.encrypt(DateUtil.dateTime2Str(this.registTime)));
		tb.setAttribute12(AesUtil.encrypt(DateUtil.dateTime2Str(this.lastLoginTime)));
		tb.setAttribute13(AesUtil.encrypt(this.pwdErrCount.toString()));
		tb.setAttribute14(AesUtil.encrypt(this.isLock.toString()));
		tb.setAttribute15(AesUtil.encrypt(this.isActive.toString()));
		tb.setAttribute16(AesUtil.encrypt(this.isValid.toString()));
		tb.setAttribute17(AesUtil.encrypt(this.isDelete.toString()));
		return tb;
	}

	/**
	 * This field was generated by MyBatis Generator. This field corresponds to
	 * the database column card_agent_info.id
	 *
	 * @mbggenerated
	 */
	private Long id;

	/**
	 * 代理商ID
	 *
	 * @mbggenerated
	 */
	private String agentId;

	/**
	 * 每笔交易被抽成比例
	 *
	 * @mbggenerated
	 */
	private BigDecimal rate;

	/**
	 * 用户角色
	 *
	 * @mbggenerated
	 */
	private String userRole;

	/**
	 * 上级代理ID
	 *
	 * @mbggenerated
	 */
	private String parentAgentId;

	/**
	 * 账户余额
	 *
	 * @mbggenerated
	 */
	private BigDecimal accountBalance;

	/**
	 * 用户名
	 *
	 * @mbggenerated
	 */
	private String userName;

	/**
	 * 密码
	 *
	 * @mbggenerated
	 */
	private String password;

	/**
	 * 代理商名称
	 *
	 * @mbggenerated
	 */
	private String name;

	/**
	 * 联系人
	 *
	 * @mbggenerated
	 */
	private String linkman;

	/**
	 * 联系方式
	 *
	 * @mbggenerated
	 */
	private String linkmanPhone;

	/**
	 * 注册时间
	 *
	 * @mbggenerated
	 */
	private Date registTime;

	/**
	 * 最后登录时间
	 *
	 * @mbggenerated
	 */
	private Date lastLoginTime;

	/**
	 * 密码错误次数
	 *
	 * @mbggenerated
	 */
	private Integer pwdErrCount;

	/**
	 * 是否锁定
	 *
	 * @mbggenerated
	 */
	private Integer isLock;

	/**
	 * 是否激活
	 *
	 * @mbggenerated
	 */
	private Integer isActive;

	/**
	 * 是否有效
	 *
	 * @mbggenerated
	 */
	private Integer isValid;

	/**
	 * 是否删除
	 *
	 * @mbggenerated
	 */
	private Integer isDelete;

	/**
	 * 获取
	 *
	 * @return id
	 *
	 * @mbggenerated
	 */
	public Long getId() {
		return id;
	}

	/**
	 * 设置
	 *
	 * @param id
	 *
	 * @mbggenerated
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * 获取代理商ID
	 *
	 * @return agentId 代理商ID
	 *
	 * @mbggenerated
	 */
	public String getAgentId() {
		return agentId;
	}

	/**
	 * 设置代理商ID
	 *
	 * @param agentId
	 *            代理商ID
	 *
	 * @mbggenerated
	 */
	public void setAgentId(String agentId) {
		this.agentId = agentId == null ? null : agentId.trim();
	}

	/**
	 * 获取每笔交易被抽成比例
	 *
	 * @return rate 每笔交易被抽成比例
	 *
	 * @mbggenerated
	 */
	public BigDecimal getRate() {
		return rate;
	}

	/**
	 * 设置每笔交易被抽成比例
	 *
	 * @param rate
	 *            每笔交易被抽成比例
	 *
	 * @mbggenerated
	 */
	public void setRate(BigDecimal rate) {
		this.rate = rate;
	}

	/**
	 * 获取用户角色
	 *
	 * @return userRole 用户角色
	 *
	 * @mbggenerated
	 */
	public String getUserRole() {
		return userRole;
	}

	/**
	 * 设置用户角色
	 *
	 * @param userRole
	 *            用户角色
	 *
	 * @mbggenerated
	 */
	public void setUserRole(String userRole) {
		this.userRole = userRole == null ? null : userRole.trim();
	}

	/**
	 * 获取上级代理ID
	 *
	 * @return parentAgentId 上级代理ID
	 *
	 * @mbggenerated
	 */
	public String getParentAgentId() {
		return parentAgentId;
	}

	/**
	 * 设置上级代理ID
	 *
	 * @param parentAgentId
	 *            上级代理ID
	 *
	 * @mbggenerated
	 */
	public void setParentAgentId(String parentAgentId) {
		this.parentAgentId = parentAgentId == null ? null : parentAgentId.trim();
	}

	/**
	 * 获取账户余额
	 *
	 * @return accountBalance 账户余额
	 *
	 * @mbggenerated
	 */
	public BigDecimal getAccountBalance() {
		return accountBalance;
	}

	/**
	 * 设置账户余额
	 *
	 * @param accountBalance
	 *            账户余额
	 *
	 * @mbggenerated
	 */
	public void setAccountBalance(BigDecimal accountBalance) {
		this.accountBalance = accountBalance;
	}

	/**
	 * 获取用户名
	 *
	 * @return userName 用户名
	 *
	 * @mbggenerated
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * 设置用户名
	 *
	 * @param userName
	 *            用户名
	 *
	 * @mbggenerated
	 */
	public void setUserName(String userName) {
		this.userName = userName == null ? null : userName.trim();
	}

	/**
	 * 获取密码
	 *
	 * @return password 密码
	 *
	 * @mbggenerated
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * 设置密码
	 *
	 * @param password
	 *            密码
	 *
	 * @mbggenerated
	 */
	public void setPassword(String password) {
		this.password = password == null ? null : password.trim();
	}

	/**
	 * 获取代理商名称
	 *
	 * @return name 代理商名称
	 *
	 * @mbggenerated
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置代理商名称
	 *
	 * @param name
	 *            代理商名称
	 *
	 * @mbggenerated
	 */
	public void setName(String name) {
		this.name = name == null ? null : name.trim();
	}

	/**
	 * 获取联系人
	 *
	 * @return linkman 联系人
	 *
	 * @mbggenerated
	 */
	public String getLinkman() {
		return linkman;
	}

	/**
	 * 设置联系人
	 *
	 * @param linkman
	 *            联系人
	 *
	 * @mbggenerated
	 */
	public void setLinkman(String linkman) {
		this.linkman = linkman == null ? null : linkman.trim();
	}

	/**
	 * 获取联系方式
	 *
	 * @return linkmanPhone 联系方式
	 *
	 * @mbggenerated
	 */
	public String getLinkmanPhone() {
		return linkmanPhone;
	}

	/**
	 * 设置联系方式
	 *
	 * @param linkmanPhone
	 *            联系方式
	 *
	 * @mbggenerated
	 */
	public void setLinkmanPhone(String linkmanPhone) {
		this.linkmanPhone = linkmanPhone == null ? null : linkmanPhone.trim();
	}

	/**
	 * 获取注册时间
	 *
	 * @return registTime 注册时间
	 *
	 * @mbggenerated
	 */
	public Date getRegistTime() {
		return registTime;
	}

	/**
	 * 设置注册时间
	 *
	 * @param registTime
	 *            注册时间
	 *
	 * @mbggenerated
	 */
	public void setRegistTime(Date registTime) {
		this.registTime = registTime;
	}

	/**
	 * 获取最后登录时间
	 *
	 * @return lastLoginTime 最后登录时间
	 *
	 * @mbggenerated
	 */
	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	/**
	 * 设置最后登录时间
	 *
	 * @param lastLoginTime
	 *            最后登录时间
	 *
	 * @mbggenerated
	 */
	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	/**
	 * 获取密码错误次数
	 *
	 * @return pwdErrCount 密码错误次数
	 *
	 * @mbggenerated
	 */
	public Integer getPwdErrCount() {
		return pwdErrCount;
	}

	/**
	 * 设置密码错误次数
	 *
	 * @param pwdErrCount
	 *            密码错误次数
	 *
	 * @mbggenerated
	 */
	public void setPwdErrCount(Integer pwdErrCount) {
		this.pwdErrCount = pwdErrCount;
	}

	/**
	 * 获取是否锁定
	 *
	 * @return isLock 是否锁定
	 *
	 * @mbggenerated
	 */
	public Integer getIsLock() {
		return isLock;
	}

	/**
	 * 设置是否锁定
	 *
	 * @param isLock
	 *            是否锁定
	 *
	 * @mbggenerated
	 */
	public void setIsLock(Integer isLock) {
		this.isLock = isLock;
	}

	/**
	 * 获取是否激活
	 *
	 * @return isActive 是否激活
	 *
	 * @mbggenerated
	 */
	public Integer getIsActive() {
		return isActive;
	}

	/**
	 * 设置是否激活
	 *
	 * @param isActive
	 *            是否激活
	 *
	 * @mbggenerated
	 */
	public void setIsActive(Integer isActive) {
		this.isActive = isActive;
	}

	/**
	 * 获取是否有效
	 *
	 * @return isValid 是否有效
	 *
	 * @mbggenerated
	 */
	public Integer getIsValid() {
		return isValid;
	}

	/**
	 * 设置是否有效
	 *
	 * @param isValid
	 *            是否有效
	 *
	 * @mbggenerated
	 */
	public void setIsValid(Integer isValid) {
		this.isValid = isValid;
	}

	/**
	 * 获取是否删除
	 *
	 * @return isDelete 是否删除
	 *
	 * @mbggenerated
	 */
	public Integer getIsDelete() {
		return isDelete;
	}

	/**
	 * 设置是否删除
	 *
	 * @param isDelete
	 *            是否删除
	 *
	 * @mbggenerated
	 */
	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}
}